package com.jiuzhi.proprietor.controller;

import com.jiuzhi.proprietor.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 测试用
 * Created by moloch on 17/9/2.
 */
@RestController
@RequestMapping(value ="em")
public class EmployeeController {

    @Autowired
    EmployeeService employeeService;

    @RequestMapping(value = "in",produces = "text/html")
    public Map<String,Object> in(HttpServletRequest request,Model model){
        model.addAttribute("list",employeeService.getEmployeeList());
//        if(1==1)throw new RuntimeException("ni");
        Map<String,Object> m = new HashMap<String,Object>();
        m.put("in","111");
        return m;
    }

    @RequestMapping
    public ModelAndView test(){

        ModelAndView mv = new ModelAndView("test");
        mv.addObject("list",employeeService.getEmployeeList());
        return mv;
    }

}
